<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>逻辑部分</title>
</head>
<body>
 <% Connection con;
    Statement sql; 
    ResultSet rs;
    
    try{  Class.forName("com.mysql.jdbc.Driver");
    }
    catch(Exception e){
       out.println("忘记把MySQL数据库的JDBC-数据库驱动程序复制到JDK的扩展目录中");
    }
    
    String uri="jdbc:mysql://127.0.0.1/worehouse";
    String user = "root";
    String password ="";
    con = DriverManager.getConnection(uri,user,password);
    sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                            ResultSet.CONCUR_READ_ONLY);
    
    String nu=request.getParameter("number");
    String na=request.getParameter("name");
    String mT=request.getParameter("madeTime");
    String pr=request.getParameter("price");
    
    float p=Float.parseFloat(pr);
    String condition = "INSERT INTO "+"product"+" VALUES"+
     "("+"'"+nu+"','"+na+"','"+mT+"',"+p+")";
    
    sql.executeUpdate(condition);
    
    rs = sql.executeQuery("SELECT * FROM " + "product");
     
      
      ResultSetMetaData meteData = rs.getMetaData();
      int columnCount = meteData.getColumnCount();


      rs.beforeFirst();
      while(rs.next()){
    	  for(int k = 0;k< columnCount;k++){
    		out.print( rs.getString(k+1));
    		
     }
    	  out.print("<br/>");
    	 
      }
      con.close();
      
    %>
</body>
</html>